home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 10 Aug 98
- // Author: mw
- //
- // Description:
- // doScaleKeyArgList is the actual proc that is executed from the
- // Edit->Keys->Scale Keys option box or menu
- //
- // Input Arguments:
- // $version: The version of this option box. Used to know how to
- // interpret the $args array.
- // "1" : $whichRange, $timeRange, $whichMethod, $newStartTime,
- // $newEndTime, $timeScale, $timePivot, $valueScale,
- // $valuePivot, $hierarchy, $doControlPoints, $doShapes,
- // $useChannelBox, $useAllAnimCurves, $selectionConnection
- // $scaleSpecifiedKeys
- // "2" : $options
- //
- // $args
- // Version 1
- // [0] $whichRange 1 : time range all
- // 2 : use playback range
- // 3 : use $timeRange
- // [1] $timeRange startTime:endTime
- // [2] $whichMethod 1 : pivot based scaling
- // 2 : newStartTime:newEndTime scaling
- // [3] $newStartTime
- // [4] $newEndTime
- // [5] $timeScale
- // [6] $timePivot
- // [7] $valueScale
- // [8] $valuePivot
- // [9] $hierarchy 1 : none
- // 2 : below
- // [10] $doControlPoints 0 / 1
- // [11] $doShapes 0 / 1
- // [12] $useChannelBox 0 / 1
- // [13] $useAllAnimCurves 0 / 1
- // [14] $selectionConnection name of selection connection to use
- // unless $options has "bufferCurve" in which
- // case this is the name of the editor
- // [15] $scaleSpecifiedKeys 0 / 1
- // Version 2
- // [16] $options a ':' delimited list of options
- // noOptions an empty placeholder
- // bufferCurve create buffer curves
- //
- // Version 3
- // [17] $fromGraphEditor 0 / 1
- // [18] $doDrivenChannels 0 / 1
- //
- // Return Value:
- // The number of curves which were scaled.
- //
- global proc int doScaleKeyArgList( string $version, string $args[] )
- {
- int $versionNum = $version;
-
- int $whichRange = $args[0];
- string $timeRange = $args[1];
- int $whichMethod = $args[2];
- float $newStartTime = $args[3];
- float $newEndTime = $args[4];
- float $timeScale = $args[5];
- float $timePivot = $args[6];
- float $valueScale = $args[7];
- float $valuePivot = $args[8];
- string $hierarchy = $args[9];
- int $doControlPoints = $args[10];
- int $doShapes = $args[11];
- int $useChannelBox = $args[12];
- int $useAllAnimCurves = $args[13];
- string $selectionConnection = $args[14];
- int $scaleSpecifiedKeys = $args[15];
- string $options = ($versionNum >= 2 ? $args[16] : "noOptions");
- int $fromGraphEditor = $versionNum >= 3 ? $args[17] : 1;
- int $doDrivenKeys = $versionNum >= 3 ? $args[18] : 1;
-
- string $cmd = "scaleKey ";
-
- // Set the scale specified key flag.
- //
- $cmd += ("-scaleSpecifiedKeys " + $scaleSpecifiedKeys + " ");
-
- string $realConnection = $selectionConnection;
-
- // Check for the bufferCurve option
- //
- if (match ("bufferCurve", $options) == "bufferCurve") {
- $realConnection = `editor -query -mainListConnection $selectionConnection`;
- // Check to see if we need to create buffer curves
- //
- if (`animCurveEditor -query -showBufferCurves $selectionConnection` == "on") {
- $cmd = "bufferCurve -animation \"keys\" -overwrite false; " + $cmd;
- }
- }
-
- // Get the target objects
- //
- string $members = expandSelectionConnection ($realConnection);
-
- if( $whichRange == 1 ) {
- $timeRange = ":";
- } else if( $whichRange == 2 ) {
- $timeRange = ( `playbackOptions -q -min` + ":" +
- `playbackOptions -q -max` );
- }
-
- int $keys = `keyframe -sl -q -kc`;
-
- if( !$fromGraphEditor || ( $keys == 0 ) ) {
- $cmd = ( $cmd + "-time \"" + $timeRange + "\" " );
-
- if( $fromGraphEditor || $doDrivenKeys ) {
- $cmd = ( $cmd + "-float \"" + $timeRange + "\" " );
- }
- }
-
- if ($whichMethod == 1) {
- $cmd += "-timeScale " + $timeScale;
- $cmd += " -timePivot " + $timePivot;
- $cmd += " -floatScale " + $timeScale;
- $cmd += " -floatPivot " + $timePivot;
- $cmd += " -valueScale " + $valueScale;
- $cmd += " -valuePivot " + $valuePivot + " ";
- }
- else {
- $cmd += "-newStartTime " + $newStartTime;
- $cmd += " -newStartFloat " + $newStartTime;
- $cmd += " -newEndTime " + $newEndTime;
- $cmd += " -newEndFloat " + $newEndTime + " ";
- }
-
- if( $useAllAnimCurves ) {
- int $i;
-
- string $curves[] = `ls -type animCurveTL`;
- for( $i = 0; $i < size( $curves ); $i++ ) {
- $cmd = ( $cmd + " " + $curves[$i] );
- }
- $curves = `ls -type animCurveTU`;
- for( $i = 0; $i < size( $curves ); $i++ ) {
- $cmd = ( $cmd + " " + $curves[$i] );
- }
- $curves = `ls -type animCurveTA`;
- for( $i = 0; $i < size( $curves ); $i++ ) {
- $cmd = ( $cmd + " " + $curves[$i] );
- }
- $curves = `ls -type animCurveTT`;
- for( $i = 0; $i < size( $curves ); $i++ ) {
- $cmd = ( $cmd + " " + $curves[$i] );
- }
- }
- else if( !$fromGraphEditor && ( $useChannelBox == 1 ) ) {
- string $syntax[] = keySetOptionBoxCommon( { "scaleKey", "unknown",
- "channelBoxSyntax" } );
- if( size( $syntax[0] ) == 0 ) {
- $cmd = "";
- warning( "No channels selected in channel box" );
- } else {
- $cmd = ( $cmd + "-hierarchy " + $hierarchy + " " );
-
- $cmd = $cmd + $syntax[0];
- }
- }
- else if( $members != "" ) {
- // Only add the selection connection to the cmd if
- // there are NO active keys (in the graph editor),
- // or we're not called from the graphEditor.
- //
- int $keys = `keyframe -sl -q -kc`;
- if( $keys == 0 || !$fromGraphEditor ) {
- if ($members == "{}") {
- $cmd = "";
- warning ("No objects selected to scale keys");
- }
- else {
- $cmd = ($cmd +
- "-hierarchy " + $hierarchy + " " +
- "-controlPoints " + $doControlPoints + " " +
- "-shape " + $doShapes + " " +
- $members);
- }
- }
- }
- else {
- $cmd = ( $cmd +
- "-animation objects " +
- "-hierarchy " + $hierarchy + " " +
- "-controlPoints " + $doControlPoints + " " +
- "-shape " + $doShapes + " " );
- }
-
- if( $cmd == "" ) {
- return 0;
- } else {
- return evalEcho( $cmd );
- }
- }
-
-